<template>
  <el-popconfirm title="确认关闭此反馈吗？" @onConfirm="close">
    <el-button
      slot="reference"
      size="mini"
      type="warning"
      class="m-l-auto"
      v-text="'关闭反馈'"
      :loading="loading"
    />
  </el-popconfirm>
</template>

<script>
import { mapActions } from 'vuex';
import { formatFeedback } from '../format';

export default {
  name: 'close-button', // 关闭反馈
  data() {
    return {
      loading: false,
    };
  },
  methods: {
    ...mapActions(['setCurrentFeedback']),
    close() {
      this.$api.feedback.reply({
        feedbackId: this.$route.params.feedbackId,
        state: 'closed',
      }).then(res => this.setCurrentFeedback(formatFeedback(res.data)))
        .catch(() => {});
    },
  },
};
</script>

<style></style>
